//
//  ViewController.swift
//  chuikitDemo
//
//  Created by cyptt on 2024/6/28.
//

import UIKit
import CHUIKit
import SnapKit
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
    var string:String?
   lazy var tableView = {()-> UITableView in
        let tabV = UITableView.init()
        tabV.delegate = self
        tabV.dataSource = self
        return tabV
    }()
    
    lazy var dataSourceArr = {()-> [String] in
        
        let dataArr = ["自定义弹窗"]
        return dataArr
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.addSubview(self.tableView)
        self.tableView.snp.makeConstraints { make in
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.width.height.equalTo(self.view)
        }
    
        
        self.tabBarItem.badgeValue = "10"
        
        self.tabBarItem.badgeValue = nil
    }


    
}


extension ViewController{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataSourceArr.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell:UITableViewCell? = tableView.dequeueReusableCell(withIdentifier: "CELLID")
        if cell == nil{
            cell = UITableViewCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: "CELLID")
        }
        cell?.textLabel?.text = self.dataSourceArr[indexPath.row] as! String
        return cell!
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let title:String = self.dataSourceArr[indexPath.row]
        if title == "自定义弹窗" {
            let vc:CLPopupController = CLPopupController()
            self.navigationController?.pushViewController(vc, animated: true)
        }else{
            
        }
    }
    
    /**
     获取类名
     */
    func getClassName(_ aClass: AnyClass) -> String {
        
        let classN: String =  NSStringFromClass(aClass )
        
       let arr:[String] = classN.components(separatedBy: ".")
      
       let lastClassName:String = arr.last ?? "";
        return lastClassName
      
    }
}




